import { BaseWindow } from "../../../component/window/BaseWindow";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { SpaListCellRenderer } from "./cell/SpaListCellRenderer";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { ScaleBitmap } from "../../../../com/mui/display/ScaleBitmap";
import { GTileList } from "../../../../com/mui/controls/GTileList";
type int = number;
//class SpaEntranceWindow
    
    export  class SpaEntranceWindow extends BaseWindow
    {
        constructor()
        {
            super();
            this.descStr1 = Language.getString(60349);
            this.descStr2 = Language.getString(60350);
            this.setSize(310, 320);
            this.title = Language.getString(60351);
            this.titleHeight = 28;
            this.addListeners();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._bg = ObjCreate.createBg(16, 40, 278, 265, this);
            this._spaListPanel = ObjCreate.createTileList(28, 45, 285, 205, this);
            this._spaListPanel.rowHeight = 40;
            this._spaListPanel.columnWidth = 270;
            this._spaListPanel.setStyle("cellRenderer", SpaListCellRenderer);
            this._descLabel1 = ObjCreate.createLabel(this.descStr1, 0, 244, 300, 20, flash.text.TextFormatAlign.CENTER, this, true, GlobalStyle.color2Uint);
            this._descLabel2 = ObjCreate.createLabel(this.descStr2, 0, 263, 300, 40, flash.text.TextFormatAlign.CENTER, this, true, GlobalStyle.color1Uint);
            return;
        }

        /* internal  */addListeners(): void
        {
            return;
        }

        public updateSpaList(arg1: Array<any>): void
        {
            if (arg1 && arg1.length > 5) 
            {
                this.setSize(310, this._spaListPanel.rowHeight * arg1.length + 120);
                this._bg.height = this.height - 55;
                this._descLabel1.y = 244 + this._spaListPanel.rowHeight * (arg1.length - 5);
                this._descLabel2.y = 263 + this._spaListPanel.rowHeight * (arg1.length - 5);
                this._spaListPanel.setSize(285, this._spaListPanel.rowHeight * arg1.length + 5);
            }
            else 
            {
                this.setSize(310, 320);
                this._bg.height = this.height - 55;
                this._descLabel1.y = 244;
                this._descLabel2.y = 263;
                this._spaListPanel.setSize(285, 205);
            }
            this._spaListPanel.dataProvider = new DataProvider(arg1);
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            Dispatcher.dispatchEvent(new DataEvent(EventName.SpaRefreshSpaList));
            if (!this._timer) 
            {
                this._timer = new Object /* flash.utils.Timer */(5000);
                this._timer.addEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
                this._timer.start();
            }
            return;
        }

        public /* override */ hide(): void
        {
            super.hide();
            if (this._timer) 
            {
                this._timer.stop();
                this._timer.removeEventListener(flash.events.TimerEvent.TIMER, this.onTimerEvent);
                this._timer = null;
            }
            return;
        }

        /* internal  */onTimerEvent(arg1: Object /* flash.events.TimerEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SpaRefreshSpaList));
            return;
        }

        /* internal */ /* var */_descLabel1: GLabel;

        /* internal */ /* var */_descLabel2: GLabel;

        /* internal */ /* var */descStr1: string;

        /* internal */ /* var */descStr2: string;

        /* internal */ /* var */_timer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_bg: ScaleBitmap;

        /* internal */ /* var */_spaListPanel: GTileList;
    }
